import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";

/* 引入ElementUI */
import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
import "@/styles/variables.less";

/* 引入axios并挂载Vue原型 */
import axios from "axios";
Vue.prototype.$axios = axios;

/* 引入并配置vue-i18n */
import VueI18n from "vue-i18n";
Vue.use(VueI18n);
import enLocale from "element-ui/lib/locale/lang/en";
import zhLocale from "element-ui/lib/locale/lang/zh-CN";

/* 自定义的国际化消息文件（后续创建） */
import en from "@/locales/en";
import zh from "@/locales/zh";

const messages = {
  en: {
    ...en,
    ...enLocale,
  },
  zh: {
    ...zh,
    ...zhLocale,
  },
};

const i18n = new VueI18n({
  locale: "zh", //默认语言
  fallbackLocale: "en",
  messages,
});

/* 注册ElementUI，并让支持i18n */
Vue.use(ElementUI, {
  i18n: (key, value) => i18n.t(key, value),
});

Vue.config.productionTip = false;

new Vue({
  router,
  store,
  i18n,
  render: (h) => h(App),
}).$mount("#app");
